package com.jl.jlapp.mvp.activity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter.OnItemChildClickListener;
import com.chad.library.adapter.base.BaseQuickAdapter.OnItemClickListener;
import com.jl.jlapp.R;
import com.jl.jlapp.adapter.CenterAdapter;
import com.jl.jlapp.eneity.Order;
import com.jl.jlapp.eneity.OrderListModel;
import com.jl.jlapp.eneity.OrderListModel.ResultDataBean;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.util.ArrayList;
import java.util.List;

public class CenterActivity
  extends AppCompatActivity
{
  public static final String TAG = "CenterActivity";
  CenterAdapter adapter;
  @BindView(R.id.no_should_evaluation_order_rela)
  RelativeLayout noShouldEvaluationOrderRela;
  List<Order> orderList;
  List<OrderListModel.ResultDataBean> orderListDataBeans;
  private ProgressDialog progressDialog;
  @BindView(R.id.return_btn)
  ImageView returnBtn;
  @BindView(R.id.rlv_enter)
  RecyclerView rlvEnter;
  List<OrderListModel.ResultDataBean> shouldShowDataBeanList;
  int userId = 0;
  
  private void setAdapter()
  {
    if (this.adapter == null)
    {
      this.rlvEnter.setLayoutManager(new LinearLayoutManager(this));
      this.adapter = new CenterAdapter(R.layout.my_order_list_item, this.shouldShowDataBeanList);
      this.rlvEnter.setAdapter(this.adapter);
    }
    else
    {
      this.adapter.setOnItemClickListener(new OnItemClickListener()
      {
        public void onItemClick(BaseQuickAdapter paramAnonymousBaseQuickAdapter, View paramAnonymousView, int paramAnonymousInt)
        {
          Intent intent = new Intent(CenterActivity.this, OrderDetailActivity.class);
          intent.putExtra("orderId", ((OrderListModel.ResultDataBean)CenterActivity.this.shouldShowDataBeanList.get(paramAnonymousInt)).getId());
          CenterActivity.this.startActivity(intent);
        }
      });
      this.adapter.setOnItemChildClickListener(new OnItemChildClickListener()
      {
        public void onItemChildClick(BaseQuickAdapter paramAnonymousBaseQuickAdapter, View paramAnonymousView, int paramAnonymousInt)
        {
          TextView tvBrn = (TextView)paramAnonymousView.findViewById(R.id.my_order_item_bottom_btn1);

          if ("评价晒单".equals(tvBrn.getText().toString().trim()))
          {
            Intent intent = new Intent(CenterActivity.this, ShouldEvaluationActivity.class);
            intent.putExtra("orderId", ((OrderListModel.ResultDataBean)CenterActivity.this.shouldShowDataBeanList.get(paramAnonymousInt)).getId());
            CenterActivity.this.startActivity(intent);
            return;
          }

          if (!"评价详情".equals(tvBrn.getText().toString().trim())){

            Intent intent = new Intent(CenterActivity.this, EvaluationDetailActivity.class);
            intent.putExtra("orderId", ((OrderListModel.ResultDataBean)CenterActivity.this.shouldShowDataBeanList.get(paramAnonymousInt)).getId());
            CenterActivity.this.startActivity(intent);
          }
        }
      });
      this.adapter.notifyDataSetChanged();
    }
  }
  
  public void buildProgressDialog()
  {
    if (this.progressDialog == null)
    {
      this.progressDialog = new ProgressDialog(this);
      this.progressDialog.setProgressStyle(0);
    }
    this.progressDialog.setMessage("加载中");
    this.progressDialog.setCancelable(true);
    this.progressDialog.show();
  }
  
  public void cancelProgressDialog()
  {
    if ((this.progressDialog != null) && (this.progressDialog.isShowing())) {
      this.progressDialog.dismiss();
    }
  }
  
  public void getOrderList(Integer paramInteger)
  {
    Net.get().getOrderList(paramInteger.intValue()).subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new CommonObserver<OrderListModel>() {
              @Override
              protected void onError(String errorMsg) {

              }

              @Override
              protected void onSuccess(OrderListModel orderListModel) {

              }
            });
  }
  
  public void getShouldShowDataListByOrderState(List<OrderListModel.ResultDataBean> paramList)
  {
    if (this.shouldShowDataBeanList == null) {
      this.shouldShowDataBeanList = new ArrayList();
    }
    this.shouldShowDataBeanList.clear();
    int i = 0;
    while (i < paramList.size())
    {
      if ((((OrderListModel.ResultDataBean)paramList.get(i)).getOrderState() == 3) || (((OrderListModel.ResultDataBean)paramList.get(i)).getOrderState() == 10) || (((OrderListModel.ResultDataBean)paramList.get(i)).getOrderState() == 8)) {
        this.shouldShowDataBeanList.add(paramList.get(i));
      }
      i += 1;
    }
  }
  
  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(R.layout.actvity_center);
    ButterKnife.bind(this);
    this.returnBtn.setOnClickListener(new OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        CenterActivity.this.finish();
      }
    });
  }
  
  public void onResume()
  {
    super.onResume();
    Log.d("aaaaaaaaMyOrder", "onResume");
    this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", 0);
    if (this.userId > 0)
    {
      buildProgressDialog();
      getOrderList(Integer.valueOf(this.userId));
      return;
    }
    Toast.makeText(this, "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
    startActivity(new Intent(this, LoginActivity.class));
  }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/CenterActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */